import service from '@/utils/request.ts'
import { getCurrentClientTime } from '@/utils'

export const fetchNewbieTask = (data: { deviceInfo: string }) => {
    return service.post('/tTaskDetail/findUserInfoNewbieTask', data)
}

export const fetchDailyTask = (data: { deviceInfo: string }) => {
    return service.post('/tTaskDetail/findUserInfoTaskCenterList', data)
}

export const fetchGameTask = (data: { device: string }) => {
    return service.post('/tGameTask/findGameTskComplete', data)
}

interface FetchReward {
    device: string,
    chaliceNum: number,
    claimType: number //1:观看三个插屏; 2: 完成游戏; 3: 页面停留; 4: 咨询站领取圣杯
    informationId?: number // informationId 仅 claimType: 4 时生效
    gameId?: number // gameId 仅 claimType: 2 时生效
}
export const fetchChaliceOfTaskReward = (data: FetchReward) => {
    return service.post('/userChailceDetail/addUserChalice', data)
}

interface UploadEventData {
    device: string,
    moduleType: number, // 1 新手任务，2 今日任务 3 每日任务
    eventType: number | string // 任务事件id
}
export const uploadTaskEventToAdmin = (data: UploadEventData) => {
    return service.post('/tTaskEvent/addTaskEvent', { ...data, reportTime: getCurrentClientTime() })
}

interface Reward {
    deviceInfo: string,
    taskId?: number,
    remarks: string,
    pointsType: number, // 每日任务 33， 游戏id领取积分 37, 咨询id领取积分 38
    points: number,
    informationId?: number // informationId 仅 pointsType: 38 时生效
    gameId?: number // gameId 仅 pointsType: 37 时生效
}
export const fetchGetReward = (data: Reward) => {
    return service.post('/tUserPointsDetail/addPointsDetailNew', data)
}